package db.pojo;

import java.util.*;
import java.text.SimpleDateFormat;
import db.ext.EadeptExt;
@SuppressWarnings("unchecked")
/**
 * eadept
 */
public class Eadept {
	/**
	 * DEPTID
	 */
	public String dEPTID;
	/**
	 * DEPTNAME
	 */
	public String dEPTNAME;
	/**
	 * PARENTID
	 */
	public String pARENTID;
	/**
	 * CUSTOMID
	 */
	public String cUSTOMID;
	/**
	 * ENABLED
	 */
	public String eNABLED;
	/**
	 * SORTNO
	 */
	public int sORTNO;
	/**
	 * LEAF
	 */
	public String lEAF;
	/**
	 * REMARK
	 */
	public String rEMARK;
	SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public static EadeptExt DB = new EadeptExt(); 
	
	public Eadept() {
		super();
	}
	
	public Eadept(String dEPTID, String dEPTNAME, String pARENTID, String cUSTOMID, String eNABLED, int sORTNO, String lEAF, String rEMARK) {
		super();
		this.dEPTID = dEPTID; 
		this.dEPTNAME = dEPTNAME; 
		this.pARENTID = pARENTID; 
		this.cUSTOMID = cUSTOMID; 
		this.eNABLED = eNABLED; 
		this.sORTNO = sORTNO; 
		this.lEAF = lEAF; 
		this.rEMARK = rEMARK; 
	}
	
	public String getDEPTID() {
		return dEPTID;
	}

	public void setDEPTID(String dEPTID) {
		this.dEPTID = dEPTID;
	} 
	
	public String getDEPTNAME() {
		return dEPTNAME;
	}

	public void setDEPTNAME(String dEPTNAME) {
		this.dEPTNAME = dEPTNAME;
	} 
	
	public String getPARENTID() {
		return pARENTID;
	}

	public void setPARENTID(String pARENTID) {
		this.pARENTID = pARENTID;
	} 
	
	public String getCUSTOMID() {
		return cUSTOMID;
	}

	public void setCUSTOMID(String cUSTOMID) {
		this.cUSTOMID = cUSTOMID;
	} 
	
	public String getENABLED() {
		return eNABLED;
	}

	public void setENABLED(String eNABLED) {
		this.eNABLED = eNABLED;
	} 
	
	public int getSORTNO() {
		return sORTNO;
	}

	public void setSORTNO(int sORTNO) {
		this.sORTNO = sORTNO;
	} 
	
	public void changeSORTNOWith(int sORTNO){
		this.sORTNO += sORTNO;
	}
	
	public void changeSORTNOWithMin(int sORTNO,int min){
		this.sORTNO += sORTNO;
		this.sORTNO = this.sORTNO < min ? min : this.sORTNO;
	}
	
	public void changeSORTNOWithMax(int sORTNO,int max){
		this.sORTNO += sORTNO;
		this.sORTNO = this.sORTNO > max ? max : this.sORTNO;
	}
	
	public void changeSORTNOWithMaxMin(int sORTNO,int max,int min){
		this.sORTNO += sORTNO;
		this.sORTNO = this.sORTNO < min ? min : this.sORTNO;
		this.sORTNO = this.sORTNO > max ? max : this.sORTNO;
	}	
	public String getLEAF() {
		return lEAF;
	}

	public void setLEAF(String lEAF) {
		this.lEAF = lEAF;
	} 
	
	public String getREMARK() {
		return rEMARK;
	}

	public void setREMARK(String rEMARK) {
		this.rEMARK = rEMARK;
	} 
	
	
	public Map eadeptToMap() {
		Map map = new HashMap();
		try {
			map.put("dEPTID",this.dEPTID);
			map.put("dEPTNAME",this.dEPTNAME);
			map.put("pARENTID",this.pARENTID);
			map.put("cUSTOMID",this.cUSTOMID);
			map.put("eNABLED",this.eNABLED);
			map.put("sORTNO",this.sORTNO);
			map.put("lEAF",this.lEAF);
			map.put("rEMARK",this.rEMARK);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return map;
	}

	public Eadept mapToEadept(Map map){
		try {
			String dEPTID =  map.get("dEPTID").toString();
			String dEPTNAME =  map.get("dEPTNAME").toString();
			String pARENTID =  map.get("pARENTID").toString();
			String cUSTOMID =  map.get("cUSTOMID").toString();
			String eNABLED =  map.get("eNABLED").toString();
			int sORTNO = Integer.parseInt( map.get("sORTNO").toString());
			String lEAF =  map.get("lEAF").toString();
			String rEMARK =  map.get("rEMARK").toString();
			Eadept eadept = new Eadept(dEPTID, dEPTNAME, pARENTID, cUSTOMID, eNABLED, sORTNO, lEAF, rEMARK);
			return eadept;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	} 
	
	public String toString(){
		return eadeptToMap().toString();
	}
	
	//方便数据操作	
	public Eadept insert(){
		return DB.insert(this);
	}
	public Eadept update(){
		return DB.update(this);
	}
	
	public int delete(){
		return DB.delete(this);
	}
	
}
